﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TravelSite.Entities
{
    public enum TravelPackageStatus
    {
        AVAILABLE = 1,
        PENDING = 2,
        BOOKED = 3,
        CANCELED = 4
    }

    public class TravelPackage
    {
        public int PackageId { get; set; }

        public decimal Cost { get; set; }
        public string CostText
        {
            get
            {
                return Cost.ToString("$#,##0.00");
            }
        }
        public string PackageName { get; set; }
        public int? VacationLength { get; set; }
        public bool CanDelete { get; set; }
        public int PkgDestId { get; set; }

        public int TravelId { get; set; }
        public string Status { get; set; }
        public string ComputedStatus
        {
            get
            {
                if (Status != "AVAILABLE")
                    return Status;
                else if ((ExpDate.HasValue) && (VacationLength.HasValue) && ((ExpDate.Value - DateTime.Now.Date).TotalDays < VacationLength.Value))
                    return "EXPIRED";
                else
                    return "AVAILABLE";
            }
        }
        public DateTime? StartDate { get; set; }
        public DateTime? EndDate 
        {
            get
            {
                DateTime? result = null;
                if (StartDate.HasValue && VacationLength.HasValue)
                    result = StartDate.Value.AddDays(VacationLength.Value);
                return result;
            }
        }
        public DateTime? ExpDate { get; set; }

        public IEnumerable<PackageDestination> Destinations { get; set; }
    }

    public class PackageDestination
    {
        public int PkgDestId { get; set; }
        public int PackageId { get; set; }
        public string DestinationName { get; set; }
        public int OptionCount { get; set; }
        public bool CanDelete { get; set; }
    }

    public class PackageDestinationOption
    {
        public int PkgDestId { get; set; }
        public int OptionId { get; set; }
        public string OptionName { get; set; }
        public int SelectedChoiceId { get; set; }
        public bool CanDelete { get; set; }
        public IEnumerable<OptionChoice> Choices { get; set; }

        public int TravelId { get; set; }
    }
}
